# -*- coding:utf-8 -*-
"""

@File : pyqtTest.py

@Author: 爸爸

@Date : 2019/5/27

@Desc :
"""
import sys

from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtWidgets import QApplication, QWidget, QToolTip, QPushButton, QMessageBox, QMainWindow, QAction, qApp
from PyQt5.QtGui import QIcon, QFont


class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):

        QToolTip.setFont(QFont('SansSerif', 15))  # 设置样式
        self.setToolTip("just fuck you!!!")  # 窗体提示框
        btn = QPushButton('提示框', self)
        btn.setToolTip("sssssssssssssssssssssssssssssssss")  # 按钮提示框
        btn.resize(btn.sizeHint())
        btn.move(50, 50)
        btn.clicked.connect(self.on_click)
        # btn.clicked.connect(QCoreApplication.instance().quit)

        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle("fuck you!!!")
        self.show()

    def closeEvent(self, event):
        reply = QMessageBox.question(self, "message", "r u sure??", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()

    def on_click(self):
        self.setWindowTitle("简直智障")


class ExampleMain(QMainWindow):
    def __init__(self):
        super().__init__()
        self.InitUi()

    def InitUi(self):
        self.statusBar().showMessage("ready")
        QToolTip.setFont(QFont("新宋体", 16))
        self.setGeometry(300, 200, 600, 450)
        self.setWindowTitle("我只是想")

        exitact = QAction("&Exit", self)
        # exitact.setShortcut('Ctrl+Q')
        exitact.setStatusTip("Exit Application")
        exitact.triggered.connect(qApp.quit)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu("&File")
        fileMenu.addAction(exitact)

        self.show()






if __name__ == '__main__':
    app = QApplication(sys.argv)
    e = ExampleMain()
    sys.exit(app.exec_())
